/*-------------------------------------------------------------------------
 * CLR版本:     4.0.30319.42000
 * 创建人:      song
 * 创建时间：   2024/4/9 17:56:20
 * 功 能：      主纹理模块
 *-------------------------------------------------------------------------*/

#if UNITY_EDITOR
namespace SCore.Editor.SShaderDraw
{
    using System.Collections.Generic;
    using UnityEditor;
    using UnityEngine;

    public class SMainProGUI : SComponentGUIBase
    {
        STextureProp _MainTex;
        SKeyWordProp _UseSceneTex;
        static bool foldout = false;

        public override void Changed()
        {
        }

        public override void DrawProperties()
        {
            if (_MainTex.Exist)
            {
                GUILayout.BeginVertical("box");
                base.DrawPartTitle(Styles.Main, ref foldout, () =>
                {
                    foreach (var p in base.lProps)
                    {
                        p.Reset();
                    }
                }, 0f);

                if (foldout)
                {
                    foreach (var prop in this.lProps)
                    {
                        prop.Draw(15f);
                    }
                }

                GUILayout.EndVertical();
            }
        }

        public override void RefreshProperties()
        {
            this.lProps.Add(_MainTex);
            this.lProps.Add(_UseSceneTex);
        }

        public SMainProGUI(MaterialEditor materialEditor, Dictionary<string, MaterialProperty> dics) : base(
            materialEditor, dics)
        {
            _MainTex = new STextureProp("_MainTex", Styles.MainTex, materialEditor, dics, null);
            _UseSceneTex = new SKeyWordProp("_UseSceneTex", Styles.UseScene, materialEditor, dics, 0f, true,
                SShaderEditorHelpr.GetInternelStyle("BoldTextField"));
        }

        private class Styles
        {
            public static GUIContent MainTex = new GUIContent("主纹理", "主纹理");
            public static GUIContent Main = new GUIContent("主模块", "主模块");
            public static GUIContent UseScene = new GUIContent("使用当前屏幕做主纹理", "使用当前屏幕做主纹理");
        }
    }
}
#endif